package com.zxmr.asyn;

import java.util.concurrent.ExecutorService;

public class AsynRequestMonitorCallBack implements MonitorCallBack{

	AsynRequest request;
	int transaction;
	@Override
	public void process(ExecutorService  worker) {
		
		// if we successfully make the request time out
		if(request.markFailed(transaction))
		{
			// need to start new thread to do the task
			worker.execute(new Runnable(){
				public void run() {
					System.out.println("task failed");
					request.requestTimeOut();
				}
			});
		}else
		{
		}
	}

	public AsynRequestMonitorCallBack(AsynRequest request)
	{
		this.request = request;
		this.transaction = request.getTransaction();
	}
}
